"""
with TreadPoolExecutor() as pool
    pool.submit(函数)
"""
import time
from concurrent.futures import ThreadPoolExecutor
def calc(num):
    time.sleep(1)
    print(f"计算{num}的平方\n")
    return num * num
if __name__ == '__main__':
    # 创建一个包含3个工作线程的线程池
    with ThreadPoolExecutor(max_workers=2) as pool:
        # 提交任务
        futures = [pool.submit(calc,num) for num in range(1,6)] # 1,2,3,4,5
        # 获取任务结果
        for f in futures:
            print(f"结果:{f.result()}")
    print("所有的计算全部完成")